package com.netease.financial.internal.di.modules;

import com.netease.financial.domain.Factory;
import com.netease.financial.domain.executor.PostExecutionThread;
import com.netease.financial.domain.executor.ThreadExecutor;
import com.netease.financial.domain.interactor.Login;
import com.netease.financial.domain.interactor.UseCase;
import com.netease.financial.domain.repository.NfsRepository;
import com.netease.financial.internal.di.ActivityScope;
import com.netease.financial.module.authentication.AuthenticationPresenter;
import com.netease.financial.module.authentication.AuthenticationPresenterImpl;

import javax.inject.Named;

import dagger.Module;
import dagger.Provides;

/**
 * Created by hzwuyufeng on 1/20/16.
 *
 * Dagger module that provides authentication related collaborators.
 */
@Module
public class AuthenticationModule {

    private final Factory<String> mClientId;
    private final Factory<String> mClientSecret;
    private final String mAppSecret;

    public AuthenticationModule(Factory<String> clientId, Factory<String> clientSecret, String appSecret) {
        super();
        mClientId = clientId;
        mClientSecret = clientSecret;
        mAppSecret = appSecret;
    }

    @Provides
    @ActivityScope
    AuthenticationPresenter provideAuthenticationPresenter(AuthenticationPresenterImpl authenticationPresenter) {
        return authenticationPresenter;
    }

    @Provides
    @ActivityScope
    @Named("login")
    UseCase provideLoginUseCase(NfsRepository nfsRepository,
                                ThreadExecutor threadExecutor,
                                PostExecutionThread postExecutionThread) {
        return new Login(mClientId, mClientSecret, mAppSecret, nfsRepository, threadExecutor, postExecutionThread);
    }
}
